function delPic(picId, userId, tag, nextPicId) {
	if (window.confirm('确定删除图片吗？')) {
		window.location.href = 'removePicture.do?picId=' + picId + '&userId='
				+ userId + '&tag=' + tag + '&type=tag&nextPicId=' + nextPicId;
	} else {
		return false;
	}
}

function viewPicture(picId, tag, userId, prePicId, nextPicId) {
	window.location.href = 'viewPictureTag.do?picId=' + picId + '&tag=' + tag
			+ '&userId=' + userId + '&prePicId=' + prePicId + '&nextPicId='
			+ nextPicId;
}

function doSubmit() {
	if (!check())
		return;
	var form = document.getElementById('mainForm');
	form.submit();
}

function check() {
	var imageFiles = document.getElementsByTagName('input');
	for (var i = 0;i < imageFiles.length; i++) {
		if (imageFiles[i].type == 'file' && imageFiles[i].value != '') {
			return true;
		}
	}
	alert('请至少选择一个图片文件');
	return false;
}

function doCancel() {
	window.history.back();
}

function getElementByName(name) {
	var elements = document.getElementsByName(name);
	return elements[0];
}

function doRegister(){
	if (!validateRegister())
		return;
	var form = document.getElementById('mainForm');
	form.submit();
}

function doLogin(){
	if (!validateLogin())
		return;
	var form = document.getElementById('mainForm');
	form.submit();
}

function validateLogin() {
	var element = document.getElementById("user.name");
	if (element.value.length == 0) {
		alert("请输入用户名");
		element.focus();
		return false;
	}
	element = document.getElementById("user.password");
	if (element.value.length == 0) {
		alert("请输入密码");
		element.focus();
		return false;
	}
	return true;
}

function validateRegister() {
	var element = document.getElementById("user.name");
	if (element.value.length == 0) {
		alert("请输入用户名");
		element.focus();
		return false;
	}
	element = document.getElementById("user.password");
	if (element.value.length == 0) {
		alert("请输入密码");
		element.focus();
		return false;
	}
	element = document.getElementById("repassword");
	if (element.value.length == 0) {
		alert("请输入确认密码");
		element.focus();
		return false;
	}
	if (element.value != document.getElementById("user.password").value) {
		alert("确认密码和原始密码不一致！");
		element.select();
		return false;
	}
	element = document.getElementById("user.dispName");
	if (element.value.length == 0) {
		alert("请输入昵称");
		element.focus();
		return false;
	}
	return true;
}